package com.itheima.springbootinit.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;

import org.springframework.core.env.Environment;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class GetValues {
    @Value("${address[0]}")
    private String address1;

    @Value("${person.name}")
    private String name;

    @Value("${msg1}")
    private String msg1;

    @Value("${msg2}")
    private String msg2;

    @Value("${person.age}")
    private int age;

    @Autowired
    private Environment env;

    @Autowired
    private Data data;

    @RequestMapping("/p")
    public String values() {
        System.out.println(address1);
        System.out.println(name);
        System.out.println(msg1);
        System.out.println(msg2);
        System.out.println(age);
        System.out.println("==================================");
        System.out.println(env.getProperty("person.name"));
        System.out.println(env.getProperty("name"));
        System.out.println("==================================");
        System.out.println(data);
        return "获取值";
    }
}
